/*!
 * @file gfxPrimitives.cpp
 * @brief Ciało gfxPrimitives.hh
 */

#include "engine/gfx/gfxPrimitives.hh"
using namespace std;

/*--------------------------------------------------------------------------*/

void gfxPrimitives::putRectangle(point2f p1, point2f p2, color cl, texture *tx) {
	pawirr::graphic->setRenderMode(RM_2D);

	if (tx != NULL) {
		glEnable(GL_TEXTURE_2D);
		glBindTexture(GL_TEXTURE_2D, tx->gltex);
	}

	glColor4f(cl.r, cl.g, cl.b, cl.a);

	glBegin(GL_QUADS);

	glTexCoord2f(0.0f, 0.0f);
	glVertex2f(p1.x, p2.y);

	glTexCoord2f(1.0f, 0.0f);
	glVertex2f(p2.x, p2.y);

	glTexCoord2f(1.0f, 1.0f);
	glVertex2f(p2.x, p1.y);

	glTexCoord2f(0.0f, 1.0f);
	glVertex2f(p1.x, p1.y);

	glEnd();

	if (tx != NULL) {
		glDisable(GL_TEXTURE_2D);
	}

	pawirr::graphic->restoreRenderMode();

}

/*--------------------------------------------------------------------------*/
